package biofilter.pipelines;

import biofilter.filters.BowtieFilter;
import biofilter.filters.RecordsFilter;
import biofilter.records.FileNameRecord;
import biofilter.sources.RecordsFile;
import biofilter.sources.RecordsSourceBase;

/**
Lets take a look at what is going on here. The pipeline is composed of only
one RecordSource, that is the RecordsFile fnrf. This is a concrete source that
inherits from the abstract class RecordsSourceBase.

Looking at the constructor, we see that RecordsFile is generic in that it
doesn't know what kind of Record it wil be returning unless you tell it.
You tell it in the second parameter to the constructor. The first parameter
is of course the file in the file system that contains a set of text records

There are no concrete filters yet (well cover these later). The concrete
source is a 'container' of records. The next record is accessed through
the source's getRecord method. We loop through the collection of records
in the execPipeline method of the Pipeline2 class making use of the eof method
of the RecordSource.
 */
class Pipeline2 {

    private RecordsFile fnrf = null;
    private BowtieFilter btf = null;

    public Pipeline2(String fileNameRecordsFile) throws Exception {
        fnrf = new RecordsFile(fileNameRecordsFile,
                "biofilter.records.FileNameRecord");
        btf = new BowtieFilter();
        btf.setSource(fnrf);
    }

    public void execPipeline() throws Exception {
        while (btf.eof() != true) {
            FileNameRecord fnr = (FileNameRecord) btf.getRecord();
            System.out.println(fnr.get());
        }
    }

    public static void main(String[] args) {
        try {
            Pipeline2 p = new Pipeline2(args[0]);
            p.execPipeline();
        } catch (Exception e) {
            System.err.println(e.getMessage());
        }
    }
}
/**


 */
 
